//
//  MOMyGetMarriedPlanEditOrCreatViewCell.m
//  MobileOffice
//
//  Created by 冰冰 on 2019/8/18.
//  Copyright © 2019 com.idolmedia. All rights reserved.
//

#import "MOMyGetMarriedPlanEditOrCreatViewCell.h"

@interface MOMyGetMarriedPlanEditOrCreatViewCell ()<UITextViewDelegate>

@property(nonatomic,strong)UITextView *textView;

@property(nonatomic,strong)UIView *lineView;

@end

@implementation MOMyGetMarriedPlanEditOrCreatViewCell

+(instancetype)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath
{
    //NSString *ID = [NSString stringWithFormat:@"Cell%ld%ld",(long)[indexPath section],(long)[indexPath row]];
    NSString *ID = @"MOMyGetMarriedPlanEditOrCreatViewCell";
    MOMyGetMarriedPlanEditOrCreatViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil){
        cell = [[MOMyGetMarriedPlanEditOrCreatViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        [cell creatView];
    }
    return cell;
}


-(void)creatView
{
    self.textView = [[UITextView alloc]initWithFrame:CGRectMake(8, 20, SCREEN_WIDTH, 100)];
    self.textView.delegate = self;
    self.textView.font = FONT_SIZE(13);
    self.textView.textColor = KBlackColor_222222;
    [self addSubview:self.textView];
    
    self.lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 139, SCREEN_WIDTH, 1)];
    self.lineView.backgroundColor = KGrayColor_ededed;
    [self addSubview:self.lineView];
}

- (void)textViewDidChange:(UITextView *)textView
{
    if (textView.text.length >= 150) {
        textView.text = [textView.text substringToIndex:150];
    }
}

-(void)textViewDidEndEditing:(UITextView *)textView
{
    if (self.textViewEndEditBlock) {
        self.textViewEndEditBlock(textView.text);
    }
}

-(void)setModel:(MOMyGetMarriedPlanEditOrCreatModel *)model
{
    if (model.contentStr.length>0) {
        _textView.placeholder = @"";
    }else{
        _textView.placeholder = model.placeStr;
    }
    _textView.text = model.contentStr;
}


@end
